Skip to content

Convert to xarray#935

Merged
davidhassell merged 15 commits into
NCAS-CMS:mainfrom
davidhassell:to-xarray-2
Jul 15, 2026
Merged

Convert to xarray#935
davidhassell merged 15 commits into
NCAS-CMS:mainfrom
davidhassell:to-xarray-2

Conversation

@davidhassell

@davidhassell davidhassell commented Mar 20, 2026

Copy link
Copy Markdown
Collaborator

Fixes #933

Needs #922 to be merged, first. - which it now is!

@davidhassell davidhassell added this to the NEXTVERSION milestone Mar 20, 2026
@davidhassell davidhassell added enhancement New feature or request dataset write Relating to writing datasets xarray Related to xarray datasets labels Mar 20, 2026
@sadielbartholomew

sadielbartholomew commented Apr 10, 2026

Copy link
Copy Markdown
Member

(Removing NETXVERSION label since we agreed this won't make it in for today's release.)

@sadielbartholomew sadielbartholomew removed this from the NEXTVERSION milestone Apr 10, 2026
@sadielbartholomew

Copy link
Copy Markdown
Member

(Now adding the new NEXTVERSION milestone, after changing the old one to 3.20.0...)

@sadielbartholomew sadielbartholomew added this to the NEXTVERSION milestone Apr 10, 2026
@sadielbartholomew sadielbartholomew modified the milestones: 3.20.1, NEXTVERSION Jun 29, 2026
@sadielbartholomew

Copy link
Copy Markdown
Member

(Now reviewing, so have went in to resolve the trivial merge conflicts on the changelog, which meant bumping the changelog lines added in this PR to a new 'NEXTVERSION' release entry, because since this PR was raised we have made that release and bumped this one back.)

@sadielbartholomew sadielbartholomew left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. +1 in particular for the thorough testing (though see point (3) below).

A few minor things e.g. a (repeated) typo, but otherwise ready to merge. Though before you do, some notes:

  • We might want to consider bumping the minimum version pinned for xarray of 2026.2.0 given that it has been some months since you put up the PR up such that xarray is now at 2026.7.0. But either is fine so that's up to you.

  • I noticed in reviewing that the Domain and DomainList classes aren't clickable in the docs (at least for the former via the mini table at https://ncas-cms.github.io/cf-python/class.html#domain-class). The latter doesn't seem to be listed under ../docs/source/class so I think it needs a stub file added there. (It would be interesting to read the docs on the latter because though I knew a FieldList was a thing I wasn't aware we had a DomainList too!)

    As for the former (Domain), are aware of some reason why that might not be clickable (otherwise will likely be some issue with the docs build I didn't notice at release time) since there is a stub file cf.Domain.rst?

  • Regarding testing, my comment from the sister cfdm PR applies here too, and they could be tackled at the same time since it is essentially the same testing:

    That said, we should definitely work towards more comprehensive testing than just asking 'is it a valid xarray dataset/tree?' after conversion to confirm that the conversion maps everything correctly,

Comment thread cf/mixin/fielddomain.py Outdated
Comment thread cf/mixin/fielddomainlist.py Outdated
Comment thread cf/test/test_xarray.py Outdated
Comment thread cf/test/test_xarray.py Outdated
Comment thread setup.py Outdated
davidhassell and others added 2 commits July 14, 2026 18:35
Co-authored-by: Sadie L. Bartholomew <sadie.bartholomew@ncas.ac.uk>
@davidhassell

Copy link
Copy Markdown
Collaborator Author

We might want to consider bumping the minimum version pinned for xarray of 2026.2.0 given that it has been some months since you put up the PR up such that xarray is now at 2026.7.0. But either is fine so that's up to you.

Yes - moved to the latest: 1304436

@davidhassell

Copy link
Copy Markdown
Collaborator Author

That said, we should definitely work towards more comprehensive testing than just asking 'is it a valid xarray dataset/tree?' after conversion to confirm that the conversion maps everything correctly,

I propose we park this until we also have "from xarray" - then we can test the round-trip of cf.Field -> xr.Dataset -> cf.Field. I suspect that the round trip won't be perfect, but we can easily test the before and after FIelds for where we expect them to match. If you agree, I'll put up an issue so that we don't forget.

@davidhassell

Copy link
Copy Markdown
Collaborator Author

I noticed in reviewing that the Domain and DomainList classes aren't clickable in the docs (at least for the former via the mini table at https://ncas-cms.github.io/cf-python/class.html#domain-class). The latter doesn't seem to be listed under ../docs/source/class so I think it needs a stub file added there. (It would be interesting to read the docs on the latter because though I knew a FieldList was a thing I wasn't aware we had a DomainList too!)

Good catch - would you like to put up an issue?

@sadielbartholomew

Copy link
Copy Markdown
Member

Yes - moved to the latest: 1304436

Nice, though it is also referenced in the setup.py and Changelog so needs updating there too.

I propose we park this until we also have "from xarray" - then we can test the round-trip of cf.Field -> xr.Dataset -> cf.Field... If you agree, I'll put up an issue so that we don't forget.

Yes, good point and that's a great plan. Agreed.

Good catch - would you like to put up an issue?

Will do!

I think this just needs a bit extra for the first point above and then we're good to go. And then we both have a follow-on Issue to write up 🙂

@davidhassell

Copy link
Copy Markdown
Collaborator Author

xarray version fixed: e7af4b5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dataset write Relating to writing datasets enhancement New feature or request xarray Related to xarray datasets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert to xarray

2 participants